\usepackage[usenames,dvipsnames]{color}    % aunque tambien puedes usar xcolor
%\usepackage{xcolor}

\definecolor{gray97}{gray}{.97}
\definecolor{gray75}{gray}{.75}
\definecolor{gray60}{gray}{.60}
\definecolor{gray45}{gray}{.45}

\definecolor{darkgray}{gray}{.95}
 \usepackage{listings}

\lstset{
  basicstyle=\footnotesize\ttfamily,
  numbers=left,
  numberstyle=\tiny,
  stepnumber=1,
  numbersep=5pt,
  backgroundcolor=\color{darkgray},
  %showspaces=false,
  showstringspaces=false,
  %showtabs=false,
  frame=single,
  tabsize=8,
  captionpos=b,
  breaklines=true,
  breakatwhitespace=true,
  %escapeinside={\%*}{*)},
  keywordstyle=\color{NavyBlue}\bfseries\bf,
  commentstyle=\color{gray60},
  identifierstyle=\color{OliveGreen},
  stringstyle=\color{BrickRed},
  texcl=true,
}

 % \lstset{ frame=Ltb,
 %  framerule=0pt,
 %  aboveskip=0.5cm,
 %  framextopmargin=3pt,
 %  framexbottommargin=3pt,
 %  framexleftmargin=0.4cm,
 %  framesep=0pt,
 %  rulesep=0.4pt,
 %  backgroundcolor=\color{gray97},
 %  rulesepcolor=\color{black},
 %  % 
 %  stringstyle=\ttfamily,
 %  showstringspaces = false,
 %  basicstyle=\small\ttfamily,
 %  commentstyle=\color{gray45},
 %  keywordstyle=\bfseries,
 %  % 
 %  numbers=left,
 %  numbersep=15pt,
 %  numberstyle=\tiny,
 %  numberfirstline = false,
 %  breaklines=true,
 %  breakatwhitespace=true,
 %  %
 %   texcl=true,
 % }

% minimizar fragmentado de listados
\lstnewenvironment{listing}[1][]
{\lstset{#1}\pagebreak[0]}{\pagebreak[0]}

\lstdefinestyle{consola}
{basicstyle=\scriptsize\bf\ttfamily,
  backgroundcolor=\color{gray75}, numbers=none,
}

\lstdefinestyle{C}
{language=C++,  lineskip=0pt,
}